import request from "@/utils/request";

// 查询订单列表
export function listOrder(query) {
  return request({
    url: "/system/order/list",
    method: "get",
    params: query,
  });
}

// 查询订单详细
export function getOrder(id) {
  return request({
    url: "/system/order/" + id,
    method: "get",
  });
}

// 新增订单
export function addOrder(data) {
  return request({
    url: "/system/order",
    method: "post",
    data: data,
  });
}

// 修改订单
export function updateOrder(data) {
  return request({
    url: "/system/order",
    method: "put",
    data: data,
  });
}

// 删除订单
export function delOrder(id) {
  return request({
    url: "/system/order/" + id,
    method: "delete",
  });
}
export function getPendingOrderCount() {
  return request({
    url: "/system/order/pending/count",
    method: "get",
  });
}
// 获取订单数量趋势数据
export function getOrderTrend(year) {
  return request({
    url: `/system/order/trend/${year}`,
    method: "get",
  });
}
// 获取农产品销售额
export function getAgriculturalSales(year) {
  return request({
    url: `/system/order/agricultural/sales/${year}`,
    method: "get",
  });
}

// 获取各月农产品销售额
export function getAgriculturalSalesByMonth(year) {
  return request({
    url: `/system/order/agricultural/sales/month/${year}`,
    method: "get",
  });
}
// 获取已支付订单的月度收入
export function getPaidOrderRevenueByMonth(year) {
  return request({
    url: `/system/order/revenue/month/${year}`,
    method: "get",
  });
}

// 获取年度已支付订单总收入
export function getAnnualPaidOrderRevenue(year) {
  return request({
    url: `/system/order/revenue/annual/${year}`,
    method: "get",
  });
}
// src/api/system/order.js
// 获取产品类型销售分布
export function getProductSalesDistribution(year) {
  return request({
    url: `/system/order/sales/distribution/${year}`,
    method: "get",
  });
}
// 获取产品类型月度销售分布数据
export function getProductSalesDistributionByMonth(year) {
  return request({
    url: `/system/order/sales/distribution/month/${year}`,
    method: "get",
  });
}

// 新增批量创建订单API
export function batchAddOrder(data) {
  return request({
    url: "/system/order/batch",
    method: "post",
    data: data,
  });
}
